set -e 

option=$1
case ${option} in
    init)
        file_name=`date "+%Y.%m.%d.md"`
        [[ -f ${file_name} ]] && echo "${file_name} exist!!!" && exit 0

        cur_time=`date "+%Y年%m月%d日 %A"`
        sed "s/<time>/${cur_time}/g" template.md > ${file_name}
        ;;
    ac)
        grep "AC:" *md | grep -v template.md
        ;;
    detail)
        grep "\- \[x\]" *md | grep -v template.md
        ;;
    miss)
        grep "\- \[\s*\]" *md | grep -v template.md
        ;;
    *)
        echo "Usage: $0 init|ac|detail|miss"
        ;;
esac
